/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFUnpackTask
  \brief abstract base class for tasks in the unpacking stage
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-10-04
  \date 2021-10-04 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-10-04   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFUnpackTask_h
#define ETFUnpackTask_h

#include "FairTask.h"

class TH1F;
class TH2F;
class TFolder;
class ETFPXISection;
class ETFVMEEvent;
class ETFVMERawEvent;

class ETFUnpackTask : public FairTask{
public:
  ETFUnpackTask(const char *name = "UnpackTask", int verbose = 1);
  virtual ~ETFUnpackTask();

  virtual void Exec(Option_t *opt);
  virtual void FinishTask();
  void SetDebug(bool opt = true){ fDebug = opt; }

  ClassDef(ETFUnpackTask, 1); // abstract base class for tasks in the unpacking stage

protected:
  virtual InitStatus Init();
  virtual void CreateHistos(); ///< create histograms for filling
  virtual void WriteHistos();

  bool fDebug; // debug or not

  ETFPXISection *fPXISection;
  ETFVMEEvent *fVMEEvent;
  ETFVMERawEvent *fVMERawEvent;

  TFolder *fFolder; ///< folder to categorize the objects in this task

  TH1F *hSecLen; ///< PXI event length
  TH1F *hCh; ///< channel distribution
  TH2F *hFragLen; ///< data length of each fragment, containing possible tables
  TH2F *htot; ///< number of leading edges v.s. channel id
  TH2F *hnlvsChid, *hntvsChid; ///< number of leading and trailing edges v.s. chid
  TH2F *hnl_ntvsChid; ///< number of leading edges - number of trailing edges v.s. chid
};

#endif
